<?
require("config.php");

$show_backnav = "product_menu";
$location_status .= "| Edit";

$menuname = array(
	"Info",
	"Pictures",
	"Color",
	"Size",
	"Specification",
	"Features",
	"Accessories",
	"Packaging",
);

$menutarget = array(
	"edit",
	"edit_pictures",
	"edit_color",
	"edit_size",
	"edit_specification",
	"edit_features",
	"edit_accessories",
	"edit_packaging",
);

$menutype = 2;

if (NULL!=$action){

	$dir = $table . "/";

	myUpload($Thumbnail,$Thumbnail_name,$dir);
	myUpload($Picture1,$Picture1_name,$dir);
	myUpload($Picture2,$Picture2_name,$dir);
	myUpload($Picture3,$Picture3_name,$dir);
	myUpload($Picture4,$Picture4_name,$dir);
	myUpload($Picture5,$Picture5_name,$dir);
	myUpload($Picture6,$Picture6_name,$dir);


	if ($Picture1_name == null) $Picture1_name = $bk_Picture1;
	if ($Picture2_name == null) $Picture2_name = $bk_Picture2;
	if ($Picture3_name == null) $Picture3_name = $bk_Picture3;
	if ($Picture4_name == null) $Picture4_name = $bk_Picture4;
	if ($Picture5_name == null) $Picture5_name = $bk_Picture5;
	if ($Picture6_name == null) $Picture6_name = $bk_Picture6;
	if ($Thumbnail_name == null) $Thumbnail_name = $bk_Thumbnail;	


	//myUpload($Thumbnail,$Thumbnail_name,$dir);
	myUpload($sm_Picture1,"sm_" . $Picture1_name,$dir);
	myUpload($sm_Picture2,"sm_" . $Picture2_name,$dir);
	myUpload($sm_Picture3,"sm_" . $Picture3_name,$dir);
	myUpload($sm_Picture4,"sm_" . $Picture4_name,$dir);
	myUpload($sm_Picture5,"sm_" . $Picture5_name,$dir);
	myUpload($sm_Picture6,"sm_" . $Picture6_name,$dir);


	if ($remove_0=="ture") $Thumbnail_name=Null;
	if ($remove_1=="ture") $Picture1_name=NULL;
	if ($remove_2=="ture") $Picture2_name=NULL;
	if ($remove_3=="ture") $Picture3_name=NULL;
	if ($remove_4=="ture") $Picture4_name=NULL;
	if ($remove_5=="ture") $Picture5_name=NULL;
	if ($remove_6=="ture") $Picture6_name=NULL;



   $field = array(
	"thumbnail",
	"picture1",
	"picture2",
	"picture3",
	"picture4",
	"picture5",
	"picture6",
	);


   $content = array(
	$Thumbnail_name,
	$Picture1_name,
	$Picture2_name,
	$Picture3_name,
	$Picture4_name,
	$Picture5_name,
	$Picture6_name,
	);

   $expression = "id=$id";

   myUpdate($table,$field,$content,$expression);

   header("location:edit_info.php?id=$id&target=edit_color&a=1");

   exit();

}


if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");
  
}

$Query = "select 
picture1,
picture2,
picture3,
picture4,
picture5,
picture6,
thumbnail 
from pro_basic where id=$id Limit 1";
$r = myQuery($Query);

$Picture1= $r[0][0];
$Picture2= $r[0][1];
$Picture3= $r[0][2];
$Picture4= $r[0][3];
$Picture5= $r[0][4];
$Picture6= $r[0][5];
$Thumbnail= $r[0][6];

require($rela_path . "inc/header.php");

?>

<!--Content Start-->
<form action="<?echo $PHP_SELF?>" method="post" enctype="multipart/form-data" name="form1">




<!--hidden filed-->
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">

<input name="bk_Picture1" type="hidden" value="<?print($Picture1)?>">
<input name="bk_Picture2" type="hidden" value="<?print($Picture2)?>">
<input name="bk_Picture3" type="hidden" value="<?print($Picture3)?>">
<input name="bk_Picture4" type="hidden" value="<?print($Picture4)?>">
<input name="bk_Picture5" type="hidden" value="<?print($Picture5)?>">
<input name="bk_Picture6" type="hidden" value="<?print($Picture6)?>">
<input name="bk_Thumbnail" type="hidden" value="<?print($Thumbnail)?>">


                    <table width="95%" border="0" align="center">
                      <tr> 
                        
      <td align="right">
	  
	  <input type="image" src="../../images/bt_cancel.gif" width="78" height="23" onclick="Redirect('product_menu.php',1);return false;"> 
        <input type="image" src="../../images/bt_save.gif" width="76" height="22"> 



      </td>
                      </tr>
                    </table>
                    <table width="95%" border="0" align="center">
                      <tr> 
                        <td align="right">&nbsp; </td>
                      </tr>
                      <tr> 
                        
      <td><table border="0" cellspacing="0" cellpadding="2">
          <tr> 
            <td class="tdheader">Thumbnail</td>
            <td>

			<?removeImage($Thumbnail,"remove_0")?>
			<?loadImage($Thumbnail,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Thumbnail" size="40">

            </td>
          </tr>


          <tr> 
            <td class="tdheader">Picture 1</td>
            <td>
			
			<?removeImage($Picture1,"remove_1")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture1,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture1" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture1,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture1" size="40">
			<br><br>


            </td>
          </tr>

          <tr> 
            <td class="tdheader">Picture 2</td>
            <td>

			<?removeImage($Picture2,"remove_2")?>			
			<?loadImage($Picture2,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture2" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture2,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture2" size="40">
			<br><br>

            </td>
          </tr>
          <tr> 
            <td class="tdheader">Picture 3</td>
            <td>
			
			<?removeImage($Picture3,"remove_3")?>
			<?loadImage($Picture3,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture3" size="40">


			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture3,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture3" size="40">
			<br><br>

            </td>
          </tr>
          <tr> 
            <td class="tdheader">Picture 4</td>
            <td>
			
			<?removeImage($Picture4,"remove_4")?>
			<?loadImage($Picture4,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture4" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture4,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture4" size="40">
			<br><br>

            </td>
          </tr>
          <tr> 
            <td class="tdheader">Picture 5</td>
            <td>
			
			<?removeImage($Picture5,"remove_5")?>
			<?loadImage($Picture5,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture5" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture5,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture5" size="40">
			<br><br>

            </td>
          </tr>
          <tr> 
            <td class="tdheader">Picture 6</td>
            <td>
			
			<?removeImage($Picture6,"remove_6")?>
			<?loadImage($Picture6,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture6" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture6,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture6" size="40">
			<br><br>

            </td>
          </tr>
        </table>
      </td>
                      </tr>
                    </table>
                    <table width="95%" border="0" align="center">
                      <tr> 
                        
      <td align="right">
	  
	  
	  <input type="image" src="../../images/bt_cancel.gif" width="78" height="23" onclick="Redirect('product_menu.php',1);return false;"> 
        <input type="image" src="../../images/bt_save.gif" width="76" height="22"> 



      </td>
                      </tr>
                    </table>
                  
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
            <!--Content End-->
            <?
require($rela_path . "inc/footer.php");
?>
        